#include "FieldBoardManager.h"
#include "SwitchRailDriverData.h"
#include "Timer.h"
#include "Communication.h"

Timer* t;

void setup ()
{
  
  Serial.begin(9600);
  Serial1.begin(9600);
  
  SwitchRailDriverData* switchRailDriverData = new SwitchRailDriverData(0x01, 13, 12);
//  TrainData* trainData1 = new TrainData(0x01, 10, 20, 30);

  FieldBoardManagerData fieldBoardManagerData = {switchRailDriverData};

  FieldBoardManager* fBM = new FieldBoardManager(fieldBoardManagerData);

  t = Timer::getTimer();
  
}

void loop(){
  t->update();
}

/**
* \brief Called when a data is detected on serial port #1
* \param none
* \return none
*/
void serialEvent1()
{
  while (Serial1.available())
  {
    Communication::byteReceived(&Serial1, Serial1.read());
  }
}
